package com.yuexun.beilunpatient.ui.contractmanage.adapter;

import android.widget.AbsListView;

import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.ui.contractmanage.bean.DiagnoseHistoryData;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;

/**
 * Created by chenss on 2018/11/30.
 */
public class DiagnoseRecordAdapter extends KJAdapter<DiagnoseHistoryData> {

    public DiagnoseRecordAdapter(AbsListView view, Collection<DiagnoseHistoryData> mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(AdapterHolder helper, DiagnoseHistoryData item, boolean isScrolling, int position) {
        super.convert(helper, item, isScrolling, position);

        SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d HH:mm:ss");
        SimpleDateFormat formatter_year = new SimpleDateFormat("yyyy");
        SimpleDateFormat formatter_day = new SimpleDateFormat("MM/dd");

        helper.setText(R.id.recorddetail_item_hospital_name,item.getHosp_name());
        helper.setText(R.id.recorddetail_item_type,"门诊");
        helper.setText(R.id.recorddetail_item_diagnosis,item.getDiag_name());
        helper.setText(R.id.recorddetail_item_doctor_name,item.getCli_doct_name());
        helper.setText(R.id.recorddetail_item_department,item.getCli_dept_name());
        Date date = null;
        try {
            date = format.parse(item.getCli_dtime());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        helper.setText(R.id.recorddetail_item_year_tv,formatter_year.format(date));
        helper.setText(R.id.recorddetail_item_date_tv,formatter_day.format(date));
    }
}
